package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TFlowDirectionInfo;
import com.ruoyi.system.service.ITFlowDirectionInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 流向信息Controller
 * 
 * @author wzy
 * @date 2024-08-29 10:50:42
 */
@RestController
@RequestMapping("/system/flow")
public class TFlowDirectionInfoController extends BaseController
{
    @Autowired
    private ITFlowDirectionInfoService tFlowDirectionInfoService;

    private static Logger logger = LoggerFactory.getLogger(TFlowDirectionInfoController.class);
    /**
     * 查询流向信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFlowDirectionInfo tFlowDirectionInfo)
    {
        startPage();
        List<TFlowDirectionInfo> list = tFlowDirectionInfoService.selectTFlowDirectionInfoList(tFlowDirectionInfo);
        return getDataTable(list);
    }

    /**
     * 导出流向信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:flow:export')")
    @Log(title = "流向信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TFlowDirectionInfo tFlowDirectionInfo)
    {
        List<TFlowDirectionInfo> list = tFlowDirectionInfoService.selectTFlowDirectionInfoList(tFlowDirectionInfo);
        ExcelUtil<TFlowDirectionInfo> util = new ExcelUtil<TFlowDirectionInfo>(TFlowDirectionInfo.class);
        util.exportExcel(response, list, "流向信息数据");
    }

    /**
     * 获取流向信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:flow:query')")
    @GetMapping(value = "/{flowDirectionId}")
    public AjaxResult getInfo(@PathVariable("flowDirectionId") Long flowDirectionId)
    {
        return success(tFlowDirectionInfoService.selectTFlowDirectionInfoByFlowDirectionId(flowDirectionId));
    }

    /**
     * 新增流向信息
     */
    @PreAuthorize("@ss.hasPermi('system:flow:add')")
    @Log(title = "流向信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFlowDirectionInfo tFlowDirectionInfo)
    {
        tFlowDirectionInfo.setCreateBy(getNickName());
        return toAjax(tFlowDirectionInfoService.insertTFlowDirectionInfo(tFlowDirectionInfo));
    }

    /**
     * 修改流向信息
     */
    @PreAuthorize("@ss.hasPermi('system:flow:edit')")
    @Log(title = "流向信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFlowDirectionInfo tFlowDirectionInfo)
    {
        tFlowDirectionInfo.setUpdateBy(getNickName());
        return toAjax(tFlowDirectionInfoService.updateTFlowDirectionInfo(tFlowDirectionInfo));
    }

    /**
     * 删除流向信息
     */
    @PreAuthorize("@ss.hasPermi('system:flow:remove')")
    @Log(title = "流向信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flowDirectionIds}")
    public AjaxResult remove(@PathVariable Long[] flowDirectionIds)
    {
        return toAjax(tFlowDirectionInfoService.deleteTFlowDirectionInfoByFlowDirectionIds(flowDirectionIds));
    }

    /**
     * 查询流向信息列表 降序click_number
     */
    //@PreAuthorize("@ss.hasPermi('system:flow:list')")
    @GetMapping("/listoption")
    public AjaxResult listoption()
    {
        return success(tFlowDirectionInfoService.selectTFlowDirectionInfoAll());
    }
}
